package com.nz.net.hays.www;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class FinalJobSearchResult extends Activity implements  OnItemClickListener{

private String jobResult;

private ListView listView ;
	
	JSONParser jsonParser = new JSONParser();
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
		.detectDiskReads().detectDiskWrites().detectNetwork()
		.penaltyLog().build());
		super.onCreate(savedInstanceState);
		setContentView(R.layout.final_jobsearch_result);
		Intent finalJobSearchResultIntent=getIntent();
		jobResult=finalJobSearchResultIntent.getExtras().getString("jobResult");
		setContentView(R.layout.final_jobsearch_result);
		
		listView = (ListView) findViewById(R.id.list);
		
		 String[] values = new String[] {jobResult};
		 
		 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
		          android.R.layout.simple_list_item_1, android.R.id.text1, values);


		        // Assign adapter to ListView
		        listView.setAdapter(adapter); 
		        
		        // ListView Item Click Listener
		        listView.setOnItemClickListener(this);
	        
	}
	
	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
		 int itemPosition     = position;
         
         // ListView Clicked item value
         String  itemValue    = (String) listView.getItemAtPosition(position);
            
          // Show Alert 
          //Toast.makeText(getApplicationContext(),
            //"Position :"+itemPosition+"  ListItem : " +itemValue , Toast.LENGTH_LONG)
            //.show();
		try {
			Intent i = new Intent(FinalJobSearchResult.this,com.sendemail.MailSenderActivity.class);
			i.putExtra("name", itemValue);
			startActivity(i);
			finish();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			 Toast.makeText(getApplicationContext(),
			            e.getMessage() , Toast.LENGTH_LONG)
			            .show();
		}
	}
	
}
